import { useState, useEffect } from 'react';
import { fetchDepartmentEvalUserCount } from '../Employee/service';

// 部门树参与考核人员数
const useDepartmentEvalUserCount = query => {
    const [resData, setResData] = useState([]);
    const [loading, setLoading] = useState(true);

    const fetchData = async () => {
        setLoading(true);
        const { data, code } = (await fetchDepartmentEvalUserCount(query)) || {};
        if (code === 10000) {
            setResData(data);
        }
        setLoading(false);
    };

    useEffect(() => {
        fetchData();
    }, [query]);

    return [loading, resData];
};

export default useDepartmentEvalUserCount;
